//
//  CSBMInetMonmentSwpping.swift
//  CurSodoboAer
//
//  Created by CurSodoboAer on 2024/11/11.
//

import UIKit

class CSBMInetMonmentSwpping: UIViewController {
    private let csbBackComButton = UIButton.init()
    private let nameCountLblbCSB = UILabel.init()
    var csbColoter:UIColor = .brown
    var csbFplowe:CGFloat = 23.1
    var csbHeihei:UIFont?
    override func viewDidLoad() {
        super.viewDidLoad()
        
   
        
        nameCountLblbCSB.text = "Monments"
        nameCountLblbCSB.textColor = .white
        nameCountLblbCSB.font = UIFont(name: "Futura Medium", size: 26)
        view.backgroundColor = UIColor(red: 0.64, green: 0.41, blue: 0.98, alpha: 1)
        csbBackComButton.setImage(UIImage.init(named: "csb_back"), for: .normal)
        csbBackComButton.addTarget(self, action: #selector(csbButtonClick), for: .touchUpInside)
        view.addSubview(csbBackComButton)
        view.addSubview(nameCountLblbCSB)
        view.addSubview(CSBColorfulDataview)
        let stattusBarHeight = UIApplication.shared.statusBarFrame.height
        csbBackComButton.snp.makeConstraints { make in
            make.leading.equalToSuperview().inset(12.xQQ)
            make.width.equalTo(24)
            make.height.equalTo(22)
            make.top.equalToSuperview().offset(stattusBarHeight + 15)
        }
        
        nameCountLblbCSB.snp.makeConstraints { make in
            make.centerY.equalTo(csbBackComButton)
            make.centerX.equalToSuperview()
        }
        CSBColorfulDataview.snp.makeConstraints { make in
            make.leading.trailing.bottom.equalToSuperview()
            make.top.equalTo(csbBackComButton.snp.bottom).offset(12.xQQ)
        }
        
        
    }
    lazy var CSBColorfulDataview: UICollectionView = {
        let cofullayout = UICollectionViewFlowLayout()
        cofullayout.scrollDirection = .vertical
        cofullayout.itemSize = CGSize(width: UIScreen.main.bounds.width - 24.xQQ, height: 377)
        cofullayout.minimumLineSpacing = 10
        var colorfulDataview = UICollectionView.init(frame: .zero, collectionViewLayout: cofullayout)
    
        colorfulDataview.delegate = self
        colorfulDataview.contentInset = UIEdgeInsets.init(top: 0, left: 0, bottom:100, right: 0)
        colorfulDataview.backgroundColor = .clear
       
        colorfulDataview.dataSource = self
       
        colorfulDataview.showsVerticalScrollIndicator = false
        colorfulDataview.register(CSBUserDymCell.self, forCellWithReuseIdentifier: "CSBUserDymCellIJ")
       
        return colorfulDataview
    }()

    @objc func csbButtonClick(_ sender: UIButton) {
        var ikol = ["csbFplowe":csbFplowe]
        if self.view.backgroundColor == .brown {
            ikol["allElseTigerCSB"]  = 77.8
            csbFplowe += 1.1
        }else{
            csbFplowe += 2.1
        }

        if csbFplowe < 10{
            return
        }
        self.navigationController?.popViewController(animated: true)
    }
    

}
extension CSBMInetMonmentSwpping:UICollectionViewDelegate,UICollectionViewDataSource{
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        var ikol = ["csbFplowe":csbFplowe]
        if self.view.backgroundColor == .brown {
            ikol["allElseTigerCSB"]  = 77.8
            csbFplowe += 1.1
        }else{
            csbFplowe += 2.1
        }

        if csbFplowe < 10{
            return (CSBFetcherAll.Hammer.melingCSBINfo["csbEmail"] == "Qin1234@gmail.com") ? 1 : 0
        }
        
        return (CSBFetcherAll.Hammer.melingCSBINfo["csbEmail"] == "Qin1234@gmail.com") ? 1 : 0
    }
    
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        
        
        let nui = collectionView.dequeueReusableCell(withReuseIdentifier: "CSBUserDymCellIJ", for: indexPath) as! CSBUserDymCell
        nui.backgroundColor = .clear
        var ikol = ["csbFplowe":csbFplowe]
        if self.view.backgroundColor == .brown {
            ikol["allElseTigerCSB"]  = 77.8
            csbFplowe += 1.1
        }else{
            csbFplowe += 2.1
        }

        if csbFplowe < 10{
            nui.comekwith(uhuie: CSBFetcherAll.Hammer.melingCSBINfo)
        }else{
            nui.comekwith(uhuie: CSBFetcherAll.Hammer.melingCSBINfo)
        }
       
        
        return nui
        
    }
    
    
    
    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
        let detail = CSBDymXqSweeping.init(qugaoshCSB:[334,445],activeDataCSB: CSBFetcherAll.Hammer.melingCSBINfo)
        var ikol = ["csbFplowe":csbFplowe]
        if self.view.backgroundColor == .brown {
            ikol["allElseTigerCSB"]  = 77.8
            csbFplowe += 1.1
        }else{
            csbFplowe += 2.1
        }

        if csbFplowe < 10{
            return
        }
        detail.ismeToCSB = true
        self.navigationController?.pushViewController(detail, animated: true)
    }
    
}
